# 修改版本时，需要确保运维已经转存相应基础镜像到华为云
ARG NODE_VERSION=14.18-stretch
ARG NGINX_VERSION=1.20.1-alpine
ARG DOCKER_REGISTER=swr.cn-east-2.myhuaweicloud.com/xinchao-test/


# 前端构建
FROM ${DOCKER_REGISTER}node:${NODE_VERSION} as build
COPY package*.json /app/
RUN set x; \
    cd /app \
    && rm -rf node_modules \
    && npm i --registry=https://mirrors.huaweicloud.com/repository/npm/
COPY . /app/
ARG ENV
RUN set -x ; \
    cd /app \
    && npm run build:${ENV}


# 部署 nginx
FROM ${DOCKER_REGISTER}nginx:${NGINX_VERSION} as nginx
ADD ./nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/run.sh /data/
COPY --from=build /app/dist/ /data/wwwroot
COPY --from=build /app/dist/ /data/wwwroot/pinmei

EXPOSE 80
ENTRYPOINT /bin/sh /data/run.sh
